Change to write current_time_tmp and then mv as current_time

Brightcells 8 years ago
parent
commit
d64645cc18
2 changed files with 6 additions and 2 deletions
  1. 1 0
      current_time
  2. 5 2
      utils/servertime.py

+ 1 - 0
current_time

@@ -0,0 +1 @@
1
+

+ 5 - 2
utils/servertime.py

@@ -1,6 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3 3
 
4
+import os
4 5
 import time
5 6
 
6 7
 
@@ -9,5 +10,7 @@ def local_string():
9 10
 
10 11
 
11 12
 def set_time(timestr):
12
-    with open('/ramfs/current_time', 'w') as f:
13
-        f.write('date -s "{}"'.format(timestr))
13
+    # with open('/ramfs/current_time', 'w') as f:
14
+    #     f.write('date -s "{}"'.format(timestr))
15
+    dates = 'date -s "{}"'.format(timestr)
16
+    os.system("echo '{}' > /ramfs/current_time_tmp; mv /ramfs/current_time_tmp /ramfs/current_time".format(dates))